//
//  LrcsModel.m
//  MyMusic
//
//  Created by ioser on 17/5/7.
//  Copyright © 2017年 ioser. All rights reserved.
//

#import "LrcsModel.h"

@implementation LrcsModel

- (instancetype)initWithLrcsName:(NSString *)lrcsName
{
    if (self = [super init]) {
        //[03:43.92]在雨下的泡沫　一触就破
        NSArray *array = [lrcsName componentsSeparatedByString:@"]"];
        self.text = [array lastObject];
        [self timeStirngDeal:[[array firstObject] substringFromIndex:1]];
        self.time = [self timeStirngDeal:[array firstObject]];
    }
    return self;
}

+ (instancetype)LrcsName:(NSString *)lrcsName
{
    return [[self alloc] initWithLrcsName:lrcsName];
}

- (NSTimeInterval)timeStirngDeal:(NSString *)string
{
    //[03:43.92
    NSArray *array = [string componentsSeparatedByString:@":"];
    NSInteger min = [[array[0] substringFromIndex:1] integerValue];
    NSInteger sec = [[array[1] substringWithRange:NSMakeRange(0, 2)] integerValue];
//    NSInteger sec = [[string substringWithRange:NSMakeRange(3, 2)] integerValue];
    NSInteger hs = [[[string componentsSeparatedByString:@"."] lastObject] integerValue];
    return min * 60 + sec + hs * 0.01;
}
@end
